package com.bix.util.blizfiles.m2;

import java.nio.ByteBuffer;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.bix.util.blizfiles.BufferUtils;
import com.jme.math.Quaternion;
import com.jme.math.Vector3f;

/**
 * This class represents a texture animation in a M2 file.
 * 
 *	@author		squid
 *
 *	@version	1.0.0
 */
public class M2TextureAnimation {
	private Log log = LogFactory.getLog (M2TextureAnimation.class);
	
	private	Vector3f			transformation;
	private	Quaternion		rotation;
	private Vector3f			scaling;

	public M2TextureAnimation () {
	}
	
	public M2TextureAnimation (ByteBuffer bb) {
		read (bb);
	}
	
	public void read (ByteBuffer bb) {
		int	position				= bb.position();
		this.transformation = BufferUtils.getVector3f(bb);
		bb.position (position + 0x1C);
		this.rotation 			= BufferUtils.getQuaternion(bb); // Is this correct?
		bb.position (position + 0x38);
		this.scaling				= BufferUtils.getVector3f(bb);
		bb.position (position + 0x54);

		log.debug ("  Transformation[" + this.getTransformation ().getX () + ","
				+ this.getTransformation ().getY () + "," + this.getTransformation ().getZ () + "]");
		log.debug ("  Rotation[" + this.getRotation () + "]");
		log.debug ("  Scaling[" + this.getScaling () + "]");
	}

	/**
	 * @return the rotation
	 */
	public Quaternion getRotation() {
		return rotation;
	}

	/**
	 * @return the transformation
	 */
	public Vector3f getTransformation() {
		return transformation;
	}

	/**
	 * @return the scaling
	 */
	public Vector3f getScaling() {
		return scaling;
	}
}
